home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / p4 / p4-1_2c.lha / p4-1.2c / messages / sr_slave.c < prev    next >
C/C++ Source or Header  |  1993-05-24  |  2KB  |  72 lines

  1. #include "p4.h"
  2. #include "sr_user.h"
  3.  
  4. slave()    
  5. {
  6.     char buf[100];
  7.     int size;
  8.     int n;
  9.     int nslaves_t;
  10.     int nslaves_l;
  11.     int start, end;
  12.     int type;
  13.     int done;
  14.     int from;
  15.     int next;
  16.     int my_id;
  17.     int my_cl_id;
  18.     int rm_ind;
  19.     char *incoming;
  20.     int start_time,end_time;
  21.     FILE *tempf;
  22.     
  23.     my_id = p4_get_my_id();
  24.     p4_dprintfl(10,"sr_slave:in slave %d\n",my_id);
  25.     /****
  26.     dump_global(5);
  27.     dump_local(5);
  28.     ****/
  29.     nslaves_t = p4_num_total_ids() - 1;
  30.  
  31.     /***/
  32.     rm_ind = p4_am_i_cluster_master();
  33.     nslaves_l = p4_num_cluster_ids() - 1;
  34.     p4_get_cluster_ids(&start, &end); 
  35.     my_cl_id = p4_get_my_cluster_id();
  36.  
  37.     p4_dprintfl(5,"p4_num_total_slaves=%d num_cluster_slaves=%d\n",
  38.         nslaves_t,nslaves_l);
  39.     p4_dprintfl(5,"first_local_id=%d last_local_id=%d\n",start,end);
  40.     p4_dprintfl(5,"my_cluster_id=%d my_id=%d rm=%d\n",
  41.          my_cl_id,my_id,rm_ind);
  42.     /***/
  43.  
  44.     if (my_id == nslaves_t)
  45.         next = 0;
  46.     else
  47.     next = my_id + 1;
  48.     done = FALSE;
  49.     while (!done)
  50.     {
  51.         p4_dprintfl(99,"sr_slave recving \n");
  52.     type = -1;
  53.     from = -1;
  54.         start_time = p4_clock();
  55.     incoming = NULL;
  56.     p4_recv(&type,&from, &incoming, &size);
  57.     p4_dprintfl(99,"sr_slave received, from=%d, type = %d\n",from,type);
  58.     if (type == END)
  59.         done = TRUE;
  60.     else 
  61.         p4_dprintfl(99,"sr_slave: got buf=\"%s\"\n",incoming);
  62.     p4_dprintfl(99,"sr_slave: slave %d sending to %d\n", my_id,next);
  63.     p4_send(type, next, incoming, size);
  64.         end_time = p4_clock();
  65.     p4_dprintfl(99,"sr_slave: slave %d sent to %d\n",my_id,next);
  66.         p4_dprintfl(5,"total time=%d \n",end_time-start_time);
  67.     p4_msg_free(incoming);
  68.     }
  69.     p4_dprintfl(10,"sr_slave %d exiting\n", p4_get_my_id());
  70. }
  71.  
  72.